#!/bin/bash

##########################################################################
# this is script check flask task
# if not running, start it!
# Author: kzeng
# Date: 2020-05-14
# */5 * * * * /home/kzeng/project-py/huluwa/check_and_run.sh
###########################################################################

# check and run it!
PIDS=`ps -ef |grep "flask" |grep -v grep | awk '{print $2}'`

echo $PIDS

if [ "$PIDS" != "" ]; then
    echo "my process flask is running ..."
else
    echo "start my task..."
    # if [ "$PIDS" != "" ]; then
    # kill -9 $PIDS
    source /home/kzeng/venv-py36/bin/activate
    export FLASK_APP=/home/kzeng/project-py/huluwa/main.py
    #export FLASK_APP=main.py
    nohup flask run --host=0.0.0.0 --port=5188 &
    # flask run --host=0.0.0.0 --port=5500 
fi
